#-------------------------------------------------------------------------------
#   Compiler
#-------------------------------------------------------------------------------
cc=g++
cco=$(cc) $(CFLAGS) $(GENERAL_INCLUDES) -o $@
#-------------------------------------------------------------------------------
#   Flags
#-------------------------------------------------------------------------------
DEBUG= -g
CFLAGS = -Wall -c $(DEBUG) -std=c++0x
LFLAGS = -Wall $(DEBUG) -std=c++0x

#-------------------------------------------------------------------------------
#   Directories
#-------------------------------------------------------------------------------
PROJECT_DIR=$(SRC)/
EXE_DIR=$(EXE)/
OBJ_DIR=$(OBJ)/
COMMON_DIR=$(PROJECT_DIR)common/
ARBOL_B_MAS_DIR=$(PROJECT_DIR)arbol-b+/
ARBOL_UB_DIR=$(PROJECT_DIR)arbol-ub/
DHASH_DIR=$(PROJECT_DIR)directoHash/
PERSISTENCIA_DIR=$(PROJECT_DIR)persistencia/
KEYS_DIR=$(PERSISTENCIA_DIR)keys/
TEST_DIR=$(PROJECT_DIR)test/

#-------------------------------------------------------------------------------
#   Includes
#-------------------------------------------------------------------------------
INCLUDE_COMMON=-I $(COMMON_DIR)
INCLUDE_ARBOL_B_MAS_DIR=-I $(ARBOL_B_MAS_DIR)
INCLUDE_ARBOL_UB=-I $(ARBOL_UB_DIR)
INCLUDE_DHASH=-I $(DHASH_DIR) -I $(KEYS_DIR)
INCLUDE_TEST=-I $(TEST_DIR)

USR_INCLUDE=/usr/include
GCC_INCLUDE=/usr/lib/gcc
LOCAL_INCLUDE=/usr/local/include


GENERAL_INCLUDES=-I $(USR_INCLUDE) -I $(GCC_INCLUDE) -I $(LOCAL_INCLUDE) $(INCLUDE_TEST) \
				$(INCLUDE_COMMON) $(INCLUDE_DHASH) $(INCLUDE_ARBOL_B_MAS_DIR) \
				$(INCLUDE_ARBOL_UB)

#-------------------------------------------------------------------------------
#   Todo
#-------------------------------------------------------------------------------

all: 	$(EXE_DIR)kdTree
	@echo 'kdTree -> Actualizado!'
	
#-------------------------------------------------------------------------------
OBJ_CAP=$(OBJ_DIR)arbolbmas.o \
		$(OBJ_DIR)binarystream.o \
		$(OBJ_DIR)container.o \
		$(OBJ_DIR)extendiblehash.o \
		$(OBJ_DIR)file.o \
		$(OBJ_DIR)nodo.o \
		$(OBJ_DIR)CargadorMasivo.o \
		$(OBJ_DIR)mapeador.o \
		$(OBJ_DIR)zcurve.o \
		$(OBJ_DIR)QueryEjecutor.o \
		$(OBJ_DIR)iteradorub.o \
		$(OBJ_DIR)main.o

#-------------------------------------------------------------------------------
#   Ejecutable
#-------------------------------------------------------------------------------

$(EXE_DIR)kdTree: $(OBJ_CAP) 
	@$S
	$(cc) $(LFLAGS) $(GENERAL_INCLUDES) $(OBJ_CAP) -o $(EXE_DIR)kdTree
	
#-------------------------------------------------------------------------------
#   Objetos Common
#-------------------------------------------------------------------------------
$(OBJ_DIR)CargadorMasivo.o: $(COMMON_DIR)CargadorMasivo.cpp
	@$S
	$(cco) $(COMMON_DIR)CargadorMasivo.cpp

$(OBJ_DIR)mapeador.o: $(COMMON_DIR)mapeador.cpp
	@$S
	$(cco) $(COMMON_DIR)mapeador.cpp
	
$(OBJ_DIR)QueryEjecutor.o: $(COMMON_DIR)QueryEjecutor.cpp
	@$S
	$(cco) $(COMMON_DIR)QueryEjecutor.cpp

#-------------------------------------------------------------------------------
#   Objetos Arbol B+
#-------------------------------------------------------------------------------
$(OBJ_DIR)arbolbmas.o: $(ARBOL_B_MAS_DIR)arbolbmas.cpp
	@$S
	$(cco) $(ARBOL_B_MAS_DIR)arbolbmas.cpp 

$(OBJ_DIR)iteradorbmas.o: $(ARBOL_B_MAS_DIR)iteradorbmas.cpp
	@$S
	$(cco) $(ARBOL_B_MAS_DIR)iteradorbmas.cpp 

$(OBJ_DIR)nodo.o: $(ARBOL_B_MAS_DIR)nodo.cpp
	@$S
	$(cco) $(ARBOL_B_MAS_DIR)nodo.cpp 
	
#-------------------------------------------------------------------------------
#   Objetos Arbol UB
#-------------------------------------------------------------------------------
$(OBJ_DIR)zcurve.o: $(ARBOL_UB_DIR)zcurve.cpp
	@$S
	$(cco) $(ARBOL_UB_DIR)zcurve.cpp
	
$(OBJ_DIR)iteradorub.o: $(ARBOL_UB_DIR)iteradorub.cpp
	@$S
	$(cco) $(ARBOL_UB_DIR)iteradorub.cpp

#-------------------------------------------------------------------------------
#   Objetos Directo Hash
#-------------------------------------------------------------------------------
$(OBJ_DIR)extendiblehash.o: $(DHASH_DIR)extendiblehash.cpp
	@$S
	$(cco) $(DHASH_DIR)extendiblehash.cpp 

#-------------------------------------------------------------------------------
#   Objetos Persistencia
#-------------------------------------------------------------------------------
$(OBJ_DIR)binarystream.o: $(PERSISTENCIA_DIR)binarystream.cpp
	@$S
	$(cco) $(PERSISTENCIA_DIR)binarystream.cpp 

$(OBJ_DIR)file.o: $(PERSISTENCIA_DIR)file.cpp
	@$S
	$(cco) $(PERSISTENCIA_DIR)file.cpp 

$(OBJ_DIR)container.o: $(PERSISTENCIA_DIR)container.cpp
	@$S
	$(cco) $(PERSISTENCIA_DIR)container.cpp 

#-------------------------------------------------------------------------------
#   Objetos Main
#-------------------------------------------------------------------------------

$(OBJ_DIR)main.o: main.cpp
	@$S
	$(cco) $(PROJECT_DIR)main.cpp
	@echo 'Generado: main.o'
	
#-------------------------------------------------------------------------------
clean :
	@$S
	rm -rf $(OBJ_CAP) kdTree 
	@echo 'Cleaned kdTree !'

#-------------------------------------------------------------------------------